package com.gyj.register.entity;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 完整的服务实例的信息
 * @author Gao
 * @date 2021/6/28
 */
public class Applications {

    /**
     * 服务注册表
     * 其实这里不用concurrentHashMap也是可以的
     * 如果是频繁的更新map中的key,value对则需要用到
     */
    private Map<String, Map<String, ServiceInstance>> registry = new ConcurrentHashMap<>();

    public Applications() {

    }

    public Applications(Map<String, Map<String, ServiceInstance>> registry) {
        this.registry = registry;
    }

    public Map<String, Map<String, ServiceInstance>> getRegistry() {
        return registry;
    }
    public void setRegistry(Map<String, Map<String, ServiceInstance>> registry) {
        this.registry = registry;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
    }
}
